<template>
    <LoadPage :show="show" />
    <view class="main" v-if="JSON.stringify(detail) != '{}'">
        <view class="swiper">
            <nut-swiper :init-page="current" auto-play="3000" :loop="true" @change="index => current = index">
                <nut-swiper-item v-for="item in detail.image.split(',')" :key="item">
                    <image :src="item" mode="aspectFill" />
                </nut-swiper-item>
                <template v-slot:page>
                    <div class="page dispaly-align-center"> {{ current }}/{{ detail.image.split(',').length }} </div>
                </template>
            </nut-swiper>
        </view>
        <view class="con">
            <view class="desc">
                <view class="title">{{ detail.title }}</view>
                <view class="dispaly-center">
                    <view class="tip dispaly-center" style="margin-right: 20rpx;">
                        <view class="tip-item">{{ detail.style }}</view>
                    </view>
                    <view class="tip dispaly-center">
                        <view class="tip-item">{{ detail.name }}</view>
                    </view>
                </view>
            </view>
            <!-- <view class="f-text dispaly-col-center">
                <view class="line-box">
                    <view class="line"></view>
                    <view class="text">我是一条分割线</view>
                    <view class="line"></view>
                </view>
                <view class="f-con">
                    <rich-text :nodes="data"></rich-text>
                </view>
            </view> -->
        </view>

    </view>
    <!-- <Option @show="bool => showO = bool" /> -->
    <button open-type="share" class="dispaly-col-center more">
        <image class="share" src="/static/icon/shra.png" />
    </button>
</template>

<script setup>
import { ref } from 'vue';
// import Option from '@/components/option/option.vue';
import { onShareAppMessage, onShareTimeline, onLoad } from '@dcloudio/uni-app';
import { getCaseDetail } from '@/api/apiList'

// 获取案例详情
let show = ref(true)
const detail = ref({})
const getDetail = async () => {
    const res = await getCaseDetail(id.value)
    if (res.code == 200) {
        detail.value = res.data
        show.value = false
    }
}


const current = ref(1)

let showO = ref(false)
onShareAppMessage(() => {
    return {
        path: `/subPackage/server/serverDetail?id=${detail.value.id}`,
        imageUrl: detail.value.detail.image.split(',')[0],
        title: detail.value.name
    };
});

onShareTimeline(() => {
    return {
        path: `/subPackage/server/serverDetail?id=${detail.value.id}`,
        imageUrl: detail.value.detail.image.split(',')[0],
        title: detail.value.name
    };
});

let id = ref('')
onLoad((option) => {
    id.value = option.id
    getDetail()
})



</script>
<style lang="scss" scoped>
.wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    height: 100%;

    .save {
        width: 284rpx;
        height: 66rpx;
        border-radius: 33rpx;
        border: 2rpx solid #FFFFFF;
        font-family: PingFang-SC, PingFang-SC;
        font-weight: bold;
        font-size: 26rpx;
        color: #FFFFFF;
        margin-top: 40rpx;
    }

    .c {
        width: 512rpx;
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20rpx;

        image {
            width: 46rpx;
            height: 46rpx;
        }
    }
}

.main {
    .con {
        padding: 30rpx;

        .desc {
            background: #FFFFFF;
            border-radius: 12rpx;
            padding: 40rpx 24rpx 24rpx 24rpx;

            .title {
                font-family: PingFang-SC, PingFang-SC;
                font-weight: 500;
                font-size: 32rpx;
                color: #111111;
                margin-bottom: 20rpx;
            }

            .tip {
                .tip-item:last-child {
                    padding-right: 0;
                    border: none;
                    margin-right: 0;
                }

                .tip-item {
                    margin-right: 10rpx;
                    border-right: 1rpx solid #999;
                    font-family: PingFang-SC, PingFang-SC;
                    font-weight: 500;
                    font-size: 24rpx;
                    color: #999999;
                    padding-right: 14rpx;
                }
            }
        }
    }

    .f-text {
        background: #FFFFFF;
        border-radius: 12rpx;
        padding: 46rpx;
        margin-top: 20rpx;

        .line-box {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .text {
            text-align: center;
            font-family: PingFang-SC, PingFang-SC;
            font-weight: 500;
            font-size: 26rpx;
            color: #333333;
            padding: 0 20rpx;
        }

        .line {
            width: 100rpx;
            height: 1px;
            background-color: #ccc;
        }

    }

    .swiper {
        image {
            width: 750rpx;
            height: 750rpx;
        }

        .page {
            width: 56rpx;
            height: 40rpx;
            background: #000000;
            border-radius: 20rpx;
            opacity: 0.5;

            position: absolute;
            bottom: 20rpx;
            right: 20rpx;
            text-align: center;
            color: #fff;
            font-size: 14px;
        }
    }
}

.more {
    position: fixed;
    bottom: 238rpx;
    right: 40rpx;

    .share {
        margin-bottom: 20rpx;
    }

    image {
        width: 74rpx;
        height: 74rpx;
    }
}

button {
    padding: 0;
    margin: 0;
}

button::after {
    border: none;
}
</style>